package com.project.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.MessageBean;
import com.project.mapper.IMessageMapper;
import com.project.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class MessageServiceImpl implements IMessageService {
    @Autowired
    private IMessageMapper mapper;

    @Override
    public void add(MessageBean message) {
        mapper.add(message);
    }

    @Override
    public void del(int id) {
        mapper.del(id);
    }

    @Override
    public void update(int id, String phone) {
        mapper.update(id,phone);
    }

    @Override
    public PageInfo<MessageBean> findByItem(int pageNo, String name) {
        PageHelper.startPage(pageNo,PAGSIZE);
        PageInfo<MessageBean> info = PageInfo.of(mapper.findByItem(name));
        return info;
    }

    @Override
    public MessageBean findById(int id) {
        return mapper.findById(id);
    }
}
